home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c,comp.unix.programmer
- Subject: Re: Q: '\n' character - Making a better fgets?
- Date: 19 Apr 1996 18:58:39 -0700
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4l9gcfINN9at@keats.ugrad.cs.ubc.ca>
- References: <31616F63.481D@lava.weeg.uiowa.edu> <4l6flq$rck@mark.ucdavis.edu> <4l8dmuINN6lf@keats.ugrad.cs.ubc.ca> <4l92qh$ft7@mark.ucdavis.edu>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4l92qh$ft7@mark.ucdavis.edu>,
- James Knight <knight@quad.cs.ucdavis.edu> wrote:
- >You were right about the getc/putc version versus the fgetc/fgetc
- >version, but that isn't what suprised me. What suprised me was that
- >the my_getline version, with it's use of fgets and strlen, was
- >faster than the getc/putc version. I wrote my_getline for simplicity,
- >to make an easier to use fgets, not for speed (since I still don't
- >have the same intuitive understanding for optimization that I do for
- >programming). So, the question I have is why did version 4 run
- >faster than version 2? From looking at the respective codes and with
- >my understanding of getc/putc versus fgets/strlen, it shouldn't have.
-
- It's quite weird. I don't understand it myself, at first glance. Care to
- report user and system times as well as elapsed times in your test? This could
- be more telling, since elapsed time can vary randomly due to system activities.
-
- I suspect that the elapsed times are due to I/O transfer time more than to CPU
- usage. My own test of freadln() on a Linux system showed about 40-90% CPU usage
- depending on the nature of the file (very short lines -> heavy CPU, long lines
- -> lower CPU usage).
-
- BTW I had not noticed on first reading that you included the freadln() function
- in your test! What have you DONE to my TABS? :))
-
- It doesn't fare all that badly considering its bloated generality.
-